/*
 * GwtYuiCarousel - API to integrate YUI Carousel in GWT framework
 *
 * Copyright (c) 2007, Nicolas Hoppenot
 *
 * This free software is licensed under the Apache License, Version 2.0 (the "License").
 * To obtain a copy of the licence, visit : http://www.apache.org/licenses/LICENSE-2.0
 *
 * This software is distributed WITHOUT ANY WARRANTY OR CONDITION OF ANY KIND.
 * Please see the license for more information.
 *
 * Version $0.6.1-beta1$
 */
package com.gwtyuicarousel.javascriptload.client;

import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Widget;
import com.gwtyuicarousel.client.ui.CarouselConfig;
import com.gwtyuicarousel.client.ui.SimpleCarouselStructure;

/**
 * The structure of this sample is identical to {@link SimpleCarouselStructure}, but we have to
 * instanciate a {@link JavaScriptLoadCarousel}. We redefine for that createCarousel method.
 * 
 * @version $0.6.1-beta1$
 * @author Nicolas Hoppenot
 * 
 */
public class JavaScriptLoadStructure
    extends SimpleCarouselStructure {

  /**
   * @see SimpleCarouselStructure#SimpleCarouselStructure(String, Widget, Widget, boolean,
   *      CarouselConfig)
   */
  public JavaScriptLoadStructure(String carouselId, Widget nextElement, Widget prevElement,
      boolean insertInCarouselDiv, CarouselConfig config) {
    super(carouselId, nextElement, prevElement, insertInCarouselDiv, config);
  }

  /**
   * Define the appropriate subclass of carousel to instanciate
   */
  protected void createCarousel() {
    // The carousel will be loaded when the listener will be affected
    config.setLoadOnStart(false);
    new JavaScriptLoadCarousel(DOM.getElementAttribute(getElement(), "id"), config);
  }

}
